#ifndef _WONTEC_RS485_H
#define _WONTEC_RS485_H

#define WONTEC_RS485_BITRATE 115200
#define WONTEC_RS485_DATABITS 8
#define WONTEC_RS485_STOPBIT 1
#define WONTEC_RS485_PARITY 'N'

#define FRAME_START_CODE 0x3E
#define FRAME_END_CODE 0x0D0A
#define MAX_WT_BUFF_LEN 128

unsigned short cal_crc(unsigned char *byte, unsigned char nbyte);

typedef struct 
{
    /* data */
    unsigned char slave_addrH;
    unsigned char slave_addrL;
    unsigned char func_code;
    unsigned char dataLen;
    unsigned char * data;
}wontec_485_frame;


int wontec_frame_serialize(wontec_485_frame * pstFrameIn,
                 unsigned char * dataBufOut, unsigned char *dataLenOut);

int wontec_frame_decode(unsigned char * dataBufIn, unsigned char dataLenIn,
                        wontec_485_frame * pstFrameOut);

typedef struct _wontec_cmd
{
    char func_code;
    unsigned char datalen;
    unsigned char data[MAX_WT_BUFF_LEN];    
}wontec_cmd;

typedef enum
{
   WONTEC_WT184_AIR_PUMP,
   WONTEC_WTAIS42_AIR_PUMP_Z,
   WONTEC_WTAIS42_JAW_Z,
   WONTEC_WTAIS42_Y,
   WONTEC_WTAIS42_X,
   WONTEC_WTAIS42_JAW,
   WONTEC_MAX_DEVID,
}en_wontec_dev;

typedef enum
{
  wontec_dev_not_init,
  wontec_dev_idle,
  wontec_dev_waiting_ack, 
  wontec_dev_act_finished, 
}en_wontec_dev_status;


#endif
